/**
业主详情页面
 **/
(function (vc) {
    vc.extends({
        data: {
            productDetailInfo: {
                productId: '',
                coverPhoto:'',
                categoryName:'',
                prodName: '',
                shName:'',
                sales: '',
                stock: '',
                price: '',
                sort: '',
                stateName: '',
                createTime: '',
                _currentTab: 'productDetailSpec',
            }
        },
        _initMethod: function () {
            $that.productDetailInfo.productId = vc.getParam('productId');
            if (!vc.notNull($that.productDetailInfo.productId)) {
                return;
            }
            $that._listProduct();

        },
        _initEvent: function () {
            vc.on('productDetail', 'listCarData', function (_info) {
                //$that._loadFeeDetailInfo();
                $that.changeTab($that.productDetailInfo._currentTab);
            });
        },
        methods: {
            _listProduct: function (_page, _rows) {

                let param = {
                    params: {
                        page:1,
                        row:1,
                        productId:$that.productDetailInfo.productId,
                        shopId:vc.getCurrentCommunity().shopId
                    }
                };

                //发送get请求
                vc.http.apiGet('/product.queryProduct',
                    param,
                    function (json, res) {
                        let _json = JSON.parse(json);
                        vc.copyObject(_json.data[0],$that.productDetailInfo);
                        $that.changeTab($that.productDetailInfo._currentTab);
                    }, function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            changeTab: function (_tab) {
                $that.productDetailInfo._currentTab = _tab;
               
                vc.emit(_tab, 'switch', {
                    productId: $that.productDetailInfo.productId,
                    prodName: $that.productDetailInfo.prodName,
                });
            },
           
        }
    });
})(window.vc);